home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / CURLPushButton 2.3 / CURLPushButton Test 68k / Other Stuff / PP Basic Starter.cp < prev    next >
Encoding:
Text File  |  1997-07-13  |  3.8 KB  |  152 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    PP Basic Starter.cp         ©1994-1996 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a basic PowerPlant application
  6.  
  7. #include "PP Basic Starter.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <PP_Messages.h>
  11. #include <PP_Resources.h>
  12. #include <UDrawingState.h>
  13. #include <UMemoryMgr.h>
  14. #include <URegistrar.h>
  15. #include <LCaption.h>
  16. #include <UModalDialogs.h>
  17.  
  18. #include <LGADialogBox.h>
  19. #include <LGAPushButton.h>
  20.  
  21. #include "CURLTestDialog.h"
  22. #include "CURLPushButton.h"
  23.  
  24.  
  25.  
  26. // ===========================================================================
  27. //        • Main Program
  28. // ===========================================================================
  29.  
  30. void main(void)
  31. {
  32.                                     // Set Debugging options
  33.     SetDebugThrow_(debugAction_Alert);
  34.     SetDebugSignal_(debugAction_Alert);
  35.  
  36.     InitializeHeap(3);                // Initialize Memory Manager
  37.                                     // Parameter is number of Master Pointer
  38.                                     //   blocks to allocate
  39.     
  40.                                     // Initialize standard Toolbox managers
  41.     UQDGlobals::InitializeToolbox(&qd);
  42.     
  43.     new LGrowZone(20000);            // Install a GrowZone function to catch
  44.                                     //    low memory situations.
  45.  
  46.     CPPStarterApp    theApp;            // replace this with your App type
  47.     theApp.Run();
  48. }
  49.  
  50.  
  51. // ---------------------------------------------------------------------------
  52. //        • CPPStarterApp             // replace this with your App type
  53. // ---------------------------------------------------------------------------
  54. //    Constructor
  55.  
  56. CPPStarterApp::CPPStarterApp()
  57. {
  58.     // Register functions to create core PowerPlant classes
  59.  
  60.     RegisterClass_(LGADialogBox);
  61.     RegisterClass_(LGAPushButton);
  62.     RegisterClass_(CURLPushButton);
  63. }
  64.  
  65.  
  66. // ---------------------------------------------------------------------------
  67. //        • ~CPPStarterApp            // replace this with your App type
  68. // ---------------------------------------------------------------------------
  69. //    Destructor
  70. //
  71.  
  72. CPPStarterApp::~CPPStarterApp()
  73. {
  74. }
  75.  
  76. // ---------------------------------------------------------------------------
  77. //        • StartUp
  78. // ---------------------------------------------------------------------------
  79. //    This function lets you do something when the application starts up
  80. //    without a document. For example, you could issue your own new command.
  81.  
  82. void
  83. CPPStarterApp::StartUp()
  84. {
  85.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  86. }
  87.  
  88. // ---------------------------------------------------------------------------
  89. //        • ObeyCommand
  90. // ---------------------------------------------------------------------------
  91. //    Respond to commands
  92.  
  93. Boolean
  94. CPPStarterApp::ObeyCommand(
  95.     CommandT    inCommand,
  96.     void        *ioParam)
  97. {
  98.     Boolean        cmdHandled = true;
  99.  
  100.     switch (inCommand) {
  101.     
  102.         // Deal with command messages (defined in PP_Messages.h).
  103.         // Any that you don't handle will be passed to LApplication
  104.              
  105.         case cmd_New:
  106.         {
  107.             CURLTestDialog::DoAboutBox( this );
  108.             SendAEQuit();
  109.         }
  110.         break;
  111.  
  112.  
  113.  
  114.         default:
  115.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  116.             break;
  117.     }
  118.     
  119.     return cmdHandled;
  120. }
  121.  
  122. // ---------------------------------------------------------------------------
  123. //        • FindCommandStatus
  124. // ---------------------------------------------------------------------------
  125. //    This function enables menu commands.
  126. //
  127.  
  128. void
  129. CPPStarterApp::FindCommandStatus(
  130.     CommandT    inCommand,
  131.     Boolean        &outEnabled,
  132.     Boolean        &outUsesMark,
  133.     Char16        &outMark,
  134.     Str255        outName)
  135. {
  136.  
  137.     switch (inCommand) {
  138.     
  139.         // Return menu item status according to command messages.
  140.         // Any that you don't handle will be passed to LApplication
  141.  
  142.         case cmd_New:                    // EXAMPLE
  143.             outEnabled = true;            // enable the New command
  144.             break;
  145.  
  146.         default:
  147.             LApplication::FindCommandStatus(inCommand, outEnabled,
  148.                                                 outUsesMark, outMark, outName);
  149.             break;
  150.     }
  151. }
  152.